﻿using System.Collections.Generic;
using UnityEngine;


namespace Super
{
	/// <summary>
	/// 这个类放置需要数据支持的函数
	///	函数数量大于4个，建议搞一个专门的manager管理
	/// </summary>
	public static class DataHelperUtil
	{
		/*********************************不随场景销毁游戏对象字典映射*************************************************/
		private static Dictionary<string, GameObject> dontDestroyObjectDict = new Dictionary<string, GameObject>();

		public static void AddDontDestroyObject(GameObject GO)
		{
			dontDestroyObjectDict[GO.name] = GO;
		}

		public static GameObject FindDontDestroyObject(string name)
		{
			if (dontDestroyObjectDict.ContainsKey(name))
				return dontDestroyObjectDict[name];

			//如果是加载生成的游戏物体名称会增加后缀"(Clone)"
			string cloneName = name + "(Clone)";
			if (dontDestroyObjectDict.ContainsKey(cloneName))
				return dontDestroyObjectDict[cloneName];

			return null;
		}
	}

}

